package tests;

import java.util.ArrayList;
import java.util.List;

import bus.Product;
import bus.ProductManager;
import junit.framework.TestCase;

public class TestProductManager extends TestCase {

	private ProductManager pm;
	
	public void setUp()
	{
		pm = new ProductManager();
		Product p = new Product();
		p.setDescription( "Chair" );
		p.setPrice( new Double( "150.10" ) );
		ArrayList aList = new ArrayList();
		aList.add(p);
		p = new Product();
		p.setDescription( "Table" );
		p.setPrice( new Double( "20.00" ) );
		aList.add( p );
		pm.setProducts( aList );
	}
	
	public void testGetProducts()
	{
		List li = pm.getProducts();
		Product p1 = (Product) li.get( 0 );
		assertEquals( "Chair" , p1.getDescription() );
		Product p2 = (Product) li.get( 1 );
		assertEquals( "Table", p2.getDescription() );
	}
	
	public void testIncreasePrice()
	{
		pm.increasePrice( 10 );
		List li = pm.getProducts();
		Product p = (Product) li.get(0);
		assertEquals( new Double( "165.11" ), p.getPrice() );
		p = (Product) li.get(1);
		assertEquals( new Double( "22.00" ), p.getPrice() );
	}
}
